package net.flyinggroup.si.integration;

import net.flyinggroup.si.model.Cargo;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.Router;

import java.util.Objects;

@MessageEndpoint
public class CargoRouter {
    @Router(inputChannel = "cargoFilterOutputChannel")
    public String route(Cargo cargo) {
        if (Objects.isNull(cargo.getShippingType())) return "nullChannel";
        switch (cargo.getShippingType()) {
            case DOMESTIC:
                return "cargoRouterDomesticOutputChannel";
            case INTERNATIONAL:
                return "cargoRouterInternationalOutputChannel";
            default:
                return "nullChannel";
        }
    }
}
